.TH std::time_get 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::time_get \- std::time_get

.SH Synopsis
   Defined in header <locale>
   template<

       class CharT,
       class InputIt = std::istreambuf_iterator<CharT>

   > class time_get;

   Class template std::time_get encapsulates date and time parsing rules. The I/O
   manipulator std::get_time uses the std::time_get facet of the I/O stream's locale to
   convert text input to a std::tm object.

   std-time get-inheritance.svg

                                   Inheritance diagram

   If a std::time_get specialization is not guaranteed to be provided by the standard
   library (see below), the behaviors of its member functions (except the constructor
   and destructor) are not guaranteed as specified.

.SH Specializations

   The standard library is guaranteed to provide the following specializations (they
   are required to be implemented by any locale object):

   Defined in header <locale>
   std::time_get<char>    parses narrow string representations of date and time
   std::time_get<wchar_t> parses wide string representations of date and time

   In addition, the standard library is also guaranteed to provide every specialization
   that satisfies the following type requirements:

     * CharT is one of char and wchar_t, and
     * InputIt must meet the requirements of LegacyInputIterator.

.SH Member types

   Member type Definition
   char_type   CharT
   iter_type   InputIt

.SH Member functions

   constructor   constructs a new time_get facet
                 \fI(public member function)\fP
   destructor    destructs a time_get facet
                 \fI(protected member function)\fP
   date_order    invokes do_date_order
                 \fI(public member function)\fP
   get_time      invokes do_get_time
                 \fI(public member function)\fP
   get_date      invokes do_get_date
                 \fI(public member function)\fP
   get_weekday   invokes do_get_weekday
                 \fI(public member function)\fP
   get_monthname invokes do_get_monthname
                 \fI(public member function)\fP
   get_year      invokes do_get_year
                 \fI(public member function)\fP
   get           invokes do_get
   \fI(C++11)\fP       \fI(public member function)\fP

.SH Member objects

   static std::locale::id id id of the locale
                             \fI(public member object)\fP

.SH Protected member functions

   do_date_order     obtains preferred ordering of day, month, and year
   \fB[virtual]\fP         \fI(virtual protected member function)\fP
   do_get_time       extracts hours, minutes, and seconds from input stream
   \fB[virtual]\fP         \fI(virtual protected member function)\fP
   do_get_date       extracts month, day, and year from input stream
   \fB[virtual]\fP         \fI(virtual protected member function)\fP
   do_get_weekday    extracts the name of a day of the week from input stream
   \fB[virtual]\fP         \fI(virtual protected member function)\fP
   do_get_monthname  extracts a month name from input stream
   \fB[virtual]\fP         \fI(virtual protected member function)\fP
   do_get_year       extracts a year from input stream
   \fB[virtual]\fP         \fI(virtual protected member function)\fP
   do_get            extracts date/time components from input stream, according to the
   \fB[virtual]\fP \fI(C++11)\fP specified format
                     \fI(virtual protected member function)\fP

Inherited from std::time_base

   Type      Definition
   dateorder date order enumeration type, defining the values no_order, dmy, mdy, ymd,
             and ydm

.SH Example

   Note: choose clang to observe the output. libstdc++ does not correctly implement
   the %b specifier: bug 78714.


// Run this code

 #include <iomanip>
 #include <iostream>
 #include <locale>
 #include <sstream>

 int main()
 {
     std::tm t = {};
     std::istringstream ss("2011-Februar-18 23:12:34");
     ss.imbue(std::locale("de_DE.utf-8"));

     ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S");
     if (ss.fail())
         std::cout << "Parse failed\\n";
     else
         std::cout << std::put_time(&t, "%c") << '\\n';
 }

.SH Possible output:

 Sun Feb 18 23:12:34 2011

.SH See also

   time_put formats contents of std::tm for output as character sequence
            \fI(class template)\fP
   get_time parses a date/time value of specified format
   \fI(C++11)\fP  \fI(function template)\fP
